package com.eos.control.action.activity;

import com.eos.business.service.SysActivityBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ActivtyMappModel;
import com.eos.orm.mybatis.model.SysActivtySon;
import com.eos.orm.mybatis.model.SysUser;

public class SaveActivityModelAction extends AbstractBaseAction {
	private static final long serialVersionUID = -4374288205758355317L;
	private Integer activtySonId;
	private Integer activtyId;
	private Integer productId;
	private Integer brandId;
	private Integer modelId;
	private String purchasePrice;
	private String firstSubsidy;
	private String secondSubsidy;
	private String thirdSubsidy;
	private String fourthSubsidy;
	private String fifthSubsidy;
	private String sixthSubsidy;
	private String mappDesc;

	public void setActivtySonId(Integer activtySonId) {
		this.activtySonId = activtySonId;
	}

	public void setActivtyId(Integer activtyId) {
		this.activtyId = activtyId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}

	public void setModelId(Integer modelId) {
		this.modelId = modelId;
	}

	public void setPurchasePrice(String purchasePrice) {
		this.purchasePrice = purchasePrice;
	}

	public void setFirstSubsidy(String firstSubsidy) {
		this.firstSubsidy = firstSubsidy;
	}

	public void setSecondSubsidy(String secondSubsidy) {
		this.secondSubsidy = secondSubsidy;
	}

	public void setThirdSubsidy(String thirdSubsidy) {
		this.thirdSubsidy = thirdSubsidy;
	}

	public void setFourthSubsidy(String fourthSubsidy) {
		this.fourthSubsidy = fourthSubsidy;
	}

	public void setFifthSubsidy(String fifthSubsidy) {
		this.fifthSubsidy = fifthSubsidy;
	}

	public void setSixthSubsidy(String sixthSubsidy) {
		this.sixthSubsidy = sixthSubsidy;
	}

	public void setMappDesc(String mappDesc) {
		this.mappDesc = mappDesc;
	}

	@Override
	public String execute() {
		try {
			SysUser user = (SysUser) getSession().getAttribute("SysUser");
			String userId = user.getId()+"";
			String strTime = ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss");
			ActivtyMappModel amm = new ActivtyMappModel();
			amm.setActivtyId(activtyId);
			amm.setActivtySonId(activtySonId);
			amm.setBrandId(brandId);
			amm.setComboConfig("0");
			amm.setDealFlag(ConstantTool.DEAL_FALG_OK);
			amm.setFifthSubsidy(fifthSubsidy);
			amm.setFirstSubsidy(firstSubsidy);
			amm.setFourthSubsidy(fourthSubsidy);
			amm.setInsertTime(strTime);
			amm.setInsertUserId(userId);
			amm.setMappDesc(mappDesc);
			amm.setModelId(modelId);
			amm.setModifyTime(strTime);
			amm.setProductId(productId);
			amm.setPurchasePrice(purchasePrice);
			amm.setSecondSubsidy(secondSubsidy);
			amm.setSixthSubsidy(sixthSubsidy);
			amm.setStatus(ConstantTool.STATUS_OK);
			amm.setThirdSubsidy(thirdSubsidy);
			amm.setUpdateUserId(userId);
			SysActivityBusinessService sabs = new SysActivityBusinessService();
			String exeStatus = sabs.saveActivityModel(amm);
			if("SUCCESS".equals(exeStatus)){
				statusCode = "200";
				message = "保存活动型号关系信息成功!";
				
				SysActivtySon sas = new SysActivtySon();
				sas.setRelationConfig("1");
				sas.setId(activtySonId);
				sabs.updateSonActivityPKSelective(sas);
			}else{
				statusCode = "300";
				message = "系统繁忙, 保存活动型号关系信息失败!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 保存活动型号关系信息失败!";
		}
		return SUCCESS;
	}
}
